<%@ page language="java" import="java.util.*" contentType="text/html"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>课程内容评估列表</title>
<link rel="stylesheet" type="text/css"
	href='<c:url value="/share/styles.css"></c:url>' />
<script src='<c:url value="/js/boot.js"></c:url>'></script>
<script src='<c:url value="/js/rqfui/rqfui.js"></c:url>'></script>
<style type="text/css">
body, html {
	width: 100%;
	height: 100%;
	margin: 0;
	font-family: "微软雅黑";
}

p {
	margin-left: 5px;
	font-size: 14px;
}

body {
	height: 100%;
	overflow: hidden;
}

.filterPan td {
	padding: 0;
}

.mini-splitter-pane {
	overflow: auto;
}

.mini-panel-body {
	padding: 0;
}

html body .searchbox .mini-buttonedit-icon {
	background: url('<c:url value="/share/img/magnifier-zoom.png"></c:url>')
		no-repeat 5% 5%;
}

.nameTitle {
	color: red;
}
.aTagUnderLine_body{
	position: absolute;
	display: none;
    z-index: 99;
	top: 0;
	left: 0;
	width:100%;
	height: 100%;
	background: rgba(0,0,0,.2);
}
.aTagUnderLine_alert{
    margin: 0 auto;
	width: 500px;
	height: 426px;
	position: relative;
	overflow: hidden;
    background: #ffffff;
    margin-top: 50px;
    z-index: 999;
    -webkit-box-shadow: 3px 3px 10px rgba(0,0,0,.8);
    box-shadow: 3px 3px 10px rgba(0,0,0,.8);
}
.aTagUnderLine_alert_title{
	position: relative;
    overflow: hidden;
    text-align: center;
	background: #2b5eae;
}
.aTagUnderLine_alert_title>div:nth-child(1){
	width: 150px;
	line-height: 33px;
	float: left;
	color: #fff;
	font-size: 14px;
}
.aTagUnderLine_alert_title>a{
	float: right;
	display: block;
	line-height: 33px;
	width: 33px;
    height: 33px;
	background: #ff6b6b;
	background: -ms-linear-gradient(top, #ff5555,  #ff7e7e);
	background:-moz-linear-gradient(top, #ff5555, #ff7e7e);
	background: -webkit-gradient(linear, 0% 0%, 0% 100%,from(#ff5555), to(#ff7e7e));
}
.aTagUnderLine_alert_title>a>img{
	margin: 12px;
}
.aTagUnderLine_alert_content{
	height: 357px;
	margin: 18px 30px;
	border: 1px solid #dddddd;
	position: relative;
    overflow: scroll;
    word-wrap: break-word;
    word-break: break-all;
}
#case_details>tr>td{
	padding-left: 50px;
	font-weight: 300;
	text-align: center;
    padding: 5px 0;
}
.table th{
	font-weight: 300;
}
.case_table>tbody>tr:nth-child(even){
	background: #edf3ff;
}
</style>
<script type="text/javascript">
	var stateValue = [ {
		id : 1,
		text : "待评估"
	}, {
		id : 2,
		text : "已评估"
	} ];
	var stateData = [ '草稿', '待评估', '评估退回', '待审核', '审核退回', '审核通过' ];
	var stateData2 = [{id:0,text:"草稿"},{id:1,text:"待评估"},{id:2,text:"评估退回"},
	                  {id:3,text:"待审核"},{id:4,text:"审核退回"},{id:5,text:"审核通过"}];
	var class1Data = [{'text':'突发'},{'text':'非突发'}];
	var class2Data = [{'text':'领事保护'},{'text':'领事协作'}];
	var class3Data = [{'text':'政局动荡'},{'text':'恐怖袭击'},{'text':'社会治安'},
	                  {'text':'自然灾害'},{'text':'意外事故'},{'text':'劳务纠纷'},
	                  {'text':'其他'}];
	var purposeData = [{'text':'旅游'},{'text':'务工'},{'text':'留学'},
		                  {'text':'科技交流'},{'text':'会议'},{'text':'商贸谈判'},
		                  {'text':'其他'}];
	var injuredData = [{'id':1,'text':'10人以下'},{'id':20,'text':'10-50人'},
	                   {'id':60,'text':'50-100人'},{'id':110,'text':'100人以上'}];
	var deathData = [{'id':1,'text':'10人以下'},{'id':20,'text':'10-30人'},
	                   {'id':40,'text':'30人以上'}];
</script>
</head>

<body>
	<div class="mini-toolbar"
		style="padding: 0px; border-width: 1px; border-bottom-width: 0px;">
		<table style="width: 100%;">
			<tr>
				<td style="width: 5px; height: 23px;"></td>
				<td width="200px"><a class="mini-button" id="rebackBtn"
					plain="true" iconCls="icon-list" onclick="status1">返回列表</a>
					<div id="typeBtn" class="mini-radiobuttonlist" repeatItems="1"
						repeatLayout="table" repeatDirection="vertical"
						style="float: left; margin-top: 4px;" textField="text"
						valueField="id" value="1" onvaluechanged="loadGrid1"
						data=stateValue></div> <a class="mini-button" id="resetBtn"
					iconCls="icon-reset" plain="true" onclick="reloadList">刷新</a></td>
				<td><a class="mini-button" id="toBackBtn" iconCls="icon-undo"
					plain="true" onclick="toBackAll">全部退回</a></td>
				<td style="width: 80px; height: 100%;">
					<div class="pageStatContainer">
						<div id="pageStatBtn_list"
							class="pageStat pageStatList pageStatListPress">
							<p>1</p>
						</div>
						<div id="pageStatBtn_form" class="pageStat pageStatForm">
							<p>2</p>
						</div>
						<div id="pageStatBtn_split" class="pageStat pageStatSplit">
							<p>3</p>
						</div>
					</div>
				</td>
			</tr>
		</table>
	</div>
	<div class="mini-fit">
		<div id="splitterPan" class="mini-splitter"
			style="width: 100%; height: 100%;" handlerSize="0">
			<div id='panLeft' size="400" showCollapseButton="true"
				style="padding: 0px; height: 100%; width: 100%;">
				<div id="datagrid1" class="mini-datagrid gridFull"
					borderStyle="border:1;" showReloadButton="true" pagesize="100"
					sizeList="[20,50,100,200]" allowCellWrap="true"
					allowHeaderWrap="true" idField="No" multiSelect="true"
					showPager="true" allowAlternating="true"
					ondrawcell="ondatagrid1DrawCell" onrowdblclick="gridRowDbClick"
					style="height: 100%; width: 100%; -moz-user-select: none; -webkit-user-select: none;"
					collapseGroupOnLoad="false" showColumnsMenu="true"
					showFilterRow="true" onshowrowdetail="onShowRowDetail">
					<div property="columns">
						<div type="indexcolumn" width="40px"></div>
						<div type="checkcolumn" width="40px" align="center"></div>
						<div field="Action" width="70px" headerAlign="center"
							align="center">
							<a class="mini-button" property="filter" id="removeBtn"
								iconCls="icon-broom" tooltip="清除筛选" onclick="removeSearch">清除
							</a>
						</div>
						<div field="state" width="80px" headerAlign="center"
							align="left" allowSort="true">
							案例状态<input id="filter0" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="id"
								data="stateData2" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect"
								allowInput="false" />
						</div>
						<div field="name" width="200px" headerAlign="center"
							align="left" allowSort="true">
							案例名称<input id="filter1" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="class1" width="65px" headerAlign="center"
							align="left" allowSort="true">
							类型一<input id="filter2" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="text"
								data="class1Data" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="class2" width="65px" headerAlign="center"
							align="left" allowSort="true">
							类型二<input id="filter3" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="text"
								data="class2Data" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="class3" width="80px" headerAlign="center"
							align="left" allowSort="true">
							类型三<input id="filter4" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="text"
								data="class3Data" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="time" width="110px" headerAlign="center"
							align="left" allowSort="true" dateFormat="yyyy-MM-dd">
							发生时间<input id="filter5" property="filter"
						class="mini-datepicker" style="width: 100%;"
						emptyText="筛选..." onvaluechanged="onselect" />
						</div>
						<div field="country_area" width="100px" headerAlign="center"
							align="left" allowSort="true">
							国家/地区<input id="filter6" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="zh_name" valueField="zh_name"
								url="<c:url value='/common/country'></c:url>" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="true" />
						</div>
						<div field="area_range" width="100px" headerAlign="center"
							align="left" allowSort="true" visible="false">
							辖区<input id="filter7" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="exit_purpose" width="100px" headerAlign="center"
							align="left" allowSort="true" visible="false">
							出境目的<input id="filter11" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="text"
								data="purposeData" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="involved_num" width="100px" headerAlign="center"
							align="left" allowSort="true" visible="false">
							涉事人数<input id="filter8" property="filter"
								class="mini-buttonedit searchbox" style="width: 100%;"
								onbuttonclick="onselect" emptyText="筛选..." onenter="onselect" />
						</div>
						<div field="injured_num" width="100px" headerAlign="center"
							align="left" allowSort="true" visible="false">
							受伤人数<input id="filter9" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="id"
								data="injuredData" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="death_num" width="100px" headerAlign="center"
							align="left" allowSort="true" visible="false">
							死亡人数<input id="filter10" property="filter"
								class="mini-combobox" style="width: 100%;"
								textField="text" valueField="id"
								data="deathData" showNullItem="true" 
								 emptyText="全部" onvaluechanged="onselect" 
								allowInput="false" />
						</div>
						<div field="creater" width="65px" headerAlign="center"
							align="center" allowSort="true">编制人</div>
						<div field="createTime" width="85px" dateFormat="yyyy-MM-dd"
							headerAlign="center" align="center" allowSort="true">编制日期</div>
						<div field="operation" width="300px" headerAlign="center"
							align="center" allowSort="true"></div>
						<div name="emptyCol" width='100%' headerAlign="center"
							align="center" cellStyle="padding:0;"></div>
					</div>
				</div>
			</div>
			<div id="panRight" showCollapseButton="true" expanded="false"
				style="overflow: hidden;">
				<iframe id=detailPan class="subPageFrame" frameborder="0">
				</iframe>
			</div>
		</div>
	</div>
	<div class="aTagUnderLine_body">
		<div class="aTagUnderLine_alert">
			<div class="aTagUnderLine_alert_title">
				<div>查看评估意见</div>
				<a href="#" onclick="closeAlert();" class="glyphicon glyphicon-remove">
					<img src="<c:url value='/share/images/Xdelete.png'></c:url>"></img>
				</a>
			</div>
			<div class="aTagUnderLine_alert_content">
				<table class="table case_table">
			    	<thead style="background: #c7e6fa; color: #2b5eae;">
				        <tr>
				          <th style="width: 170px;padding:5px 0;">评估意见</th>
				          <th style="width: 170px;padding:5px 0;">评估时间</th>
				          <th style="width: 170px;padding:5px 0;">评&nbsp;估&nbsp;人</th>
				        </tr>
				    </thead>
			      <tbody id="case_details">
			 
			      </tbody>
			    </table>
			</div>
		</div>
	</div>
	

	<script type="text/javascript">
		mini.parse();
		mini_debugger = false;
		var isKeepStat3 = false;
		var rootPath = '${rootPath}';
		var filterHelper = gridFilter();

		var datagrid1 = mini.get("datagrid1");
		var splitpan = mini.get("splitterPan");
		var typeBtn = mini.get("typeBtn");
		var filter0 = mini.get("filter0");
		var filter1 = mini.get("filter1");
		var filter2 = mini.get("filter2");
		var filter3 = mini.get("filter3");
		var filter4 = mini.get("filter4");
		var filter5 = mini.get("filter5");
		var filter6 = mini.get("filter6");
		var filter7 = mini.get("filter7");
		var filter8 = mini.get("filter8");
		var filter9 = mini.get("filter9");
		var filter10 = mini.get("filter10");
		var filter11 = mini.get("filter11");

		$(function() {
			$(".pageStat").hover(function() {
				$(this).addClass("hoverStyle");
			}, function() {
				$(this).removeClass("hoverStyle");
			});
			$(".pageStat").click(
					function() {
						$this = $(this);
						var value = $this.find("p").first().html();
						if (value == 1) {
							splitpan.collapsePane(2);
							$this.addClass("pageStatListPress");
							$this.next().removeClass("pageStatFormPress")
									.next().removeClass("pageStatSplitPress");
							isKeepStat3 = false;
							status1Show();
						}
						if (value == 2) {
							splitpan.collapsePane(1);
							$this.addClass("pageStatFormPress");
							$this.prev().removeClass("pageStatListPress");
							$this.next().removeClass("pageStatSplitPress");
							isKeepStat3 = false;
							status2Show();
						}
						if (value == 3) {
							splitpan.expandPane(1);
							splitpan.expandPane(2);
							$this.addClass("pageStatSplitPress");
							$this.prev().removeClass("pageStatFormPress")
									.prev().removeClass("pageStatListPress");
							isKeepStat3 = true;
							status3Show();
						}
					});
			status1();
			loadGrid1();
		});
		//双击
		function gridRowDbClick(e) {
			var id = e.row.id;
			var state = e.row.state;
			showDetail(id,state);
		}
		function showDetail(id,state) {
			status2();
			var url = '<c:url value="/case/check/" />'+id+'/'+state;
			$('#detailPan').css('height', '100%').css('width', '100%').attr(
					'src', url);
		}
		/* function estimate(id) {
			status2();
			$('#detailPan').css('height', '100%').css('width', '100%').attr('src',
					'<c:url value="/estimate/courseEs/" />'+id);
		} */
		function estimate(id,type) {
			var title = null;
			var info = null;
			if(type == 1){
				title = '评估通过';
				info = '请输入评估通过意见：';
			}else if(type == 0){
				title = '评估退回';
				info = '请输入评估退回意见：';
			}else{
				return;
			}
	        mini.prompt(info, title,
	            function (action, value) {
	                if (action == "ok") {
	                    estimateConfirm(id,type,value);
	                } else {
	                    return;
	                }
	            },
	            true
	        );
	    }
		function estimateConfirm(id,type,value){
			$.ajax({
				url : '<c:url value="/estimate/caseEs/" />'+type+'/'+id,
				type : "post",
				dataType : 'html',
				data : {
					"content" : value
				},
				success : function(text) {
					if(text && 'true' == text){
						//top.commonTools.showTip("操作成功", 1);
						reloadList();
					}
				},
				complete : function(XMLHttpRequest, textStatus) {
				},
				error : function() {
					top.commonTools.showTip("操作发生错误", 2);
				}
			});
		}
		function onselect() {
			var filterValue0 = filter0.getValue();
			var filterValue1 = filter1.getValue();
			var filterValue2 = filter2.getValue();
			var filterValue3 = filter3.getValue();
			var filterValue4 = filter4.getValue();
			var filterValue5 = filter5.getValue();
			var filterValue6 = filter6.getValue();
			var filterValue7 = filter7.getValue();
			var filterValue8 = filter8.getValue();
			var filterValue9 = filter9.getValue();
			var filterValue10 = filter10.getValue();
			var filterValue11 = filter11.getValue();
			filterHelper.clearFilterData();
			if (filterValue0 != "") {
				var filterdata = filterHelper.formFilterData("state",
						filterValue0, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue1 != "") {
				var filterdata = filterHelper.formFilterData("name",
						filterValue1, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue2 != "") {
				var filterdata = filterHelper.formFilterData("class1",
						filterValue2, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue3 != "") {
				var filterdata = filterHelper.formFilterData("class2",
						filterValue3, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue4 != "") {
				var filterdata = filterHelper.formFilterData("class3",
						filterValue4, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue5 != "") {
				var filterdata = filterHelper.formFilterData("time",
						filterValue5, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue6 != "") {
				var filterdata = filterHelper.formFilterData("country_area",
						filterValue6, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue7 != "") {
				var filterdata = filterHelper.formFilterData("area_range",
						filterValue7, '', 'CONTAIN', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue8 != "") {
				var filterdata = filterHelper.formFilterData("involved_num",
						filterValue8, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue9 != "") {
				var filterdata = filterHelper.formFilterData("injured_num",
						filterValue9, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue10 != "") {
				var filterdata = filterHelper.formFilterData("death_num",
						filterValue10, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			if (filterValue11 != "") {
				var filterdata = filterHelper.formFilterData("exit_purpose",
						filterValue11, '', 'EQUALS', 'AND');
				filterHelper.addFilterData(filterdata);
			}
			loadGrid1();
		}
		function loadGrid1() {
			var filterData = filterHelper.getFilterData();
			var postData = new Object();
			if (filterData != null || filterData.length > 0) {
				postData.filterdata = mini.encode(filterData);
			}
			var type = typeBtn.getValue();
			var url = "<c:url value='/estimate/caseList/' />" + type;
			datagrid1.load(url);
			datagrid1.load(postData);
		}
		function removeSearch() {
			filter0.setValue();
			filter1.setValue();
			filter1.setText();
			filter2.setValue();
			filter3.setValue();
			filter4.setValue();
			filter5.setValue();
			filter6.setValue();
			filter7.setText();
			filter7.setValue();
			filter8.setText();
			filter8.setValue();
			filter9.setText();
			filter9.setValue();
			filter10.setText();
			filter10.setValue();
			filter11.setValue();
			filterHelper.clearFilterData();
			loadGrid1();

		}
		function ondatagrid1DrawCell(e) {
			var row = e.row;
			var field = e.field;
			var state = row.state;
			if (field == "Action") {
				var id = row.id;
				e.cellHtml = '<a class="aTagUnderLine" href="javascript:showDetail('
						+ id + ','+state+')">[查看]</a>';
			}
			if (field == "operation") {
				var id = row.id;
				var state = row.state;
				var type = typeBtn.getValue();
				if(type==1){
					if(state == 1){
						e.cellHtml = '<a class="aTagUnderLine" href="javascript:estimate(\''
							+ id + '\',\'1\')">[评估通过]&nbsp;&nbsp;</a><a class="aTagUnderLine" href="javascript:estimate(\''
							+ id + '\',\'0\')">[评估退回]</a>';
					}
				}else if(type==2){
					e.cellHtml = '<a class="aTagUnderLine"  href="javascript:aTagUnderLine_alert('+id+');">[查看评估意见]&nbsp;&nbsp;</a>';
				}
			}
			if (field == "state") {
				e.cellHtml = stateData[parseInt(row.state)];
			}
			if (field == "injured_num") {
				var value = e.value;
				var valueStr = "未知";
				switch(value){
				case 1:
					valueStr ='10人以下';
					break;
				case 20:
					valueStr ='10-50人';
					break;
				case 60:
					valueStr ='50-100人';
					break;
				case 110:
					valueStr ='100人以上';
					break;
				}
				e.cellHtml = valueStr;
			}
			if (field == "death_num") {
				var value = e.value;
				var valueStr = "未知";
				switch(value){
				case 1:
					valueStr ='10人以下';
					break;
				case 20:
					valueStr ='10-30人';
					break;
				case 40:
					valueStr ='30人以上';
					break;
				}
				e.cellHtml = valueStr;
			}
		}

		function status1() {
			if (!isKeepStat3) {
				$("#pageStatBtn_list").click();
			}
		}
		function status2() {
			if (!isKeepStat3) {
				$("#pageStatBtn_form").click();
			}
		}
		function status3() {
			$("#pageStatBtn_split").click();
		}
		function status1Show() {
			$('#rebackBtn').hide();
			$('#typeBtn').show();
			$('#resetBtn').show();
			$("#toBackBtn").hide();
		}
		function status2Show() {
			$('#rebackBtn').show();
			$('#typeBtn').hide();
			$('#resetBtn').hide();
			$("#toBackBtn").hide();
		}
		function status3Show() {
			$('#rebackBtn').hide();
			$('#typeBtn').show();
			$('#resetBtn').show();
			$("#toBackBtn").hide();
		}
		function reloadList() {
			datagrid1.reload();
		}
		//点击弹出框
		function aTagUnderLine_alert(id){
			var url="<c:url value='/estimate/getEvalue/'/>"+id+"/3";
			$.ajax({
				url: url,
				type:"get",
				dataType:"json",
				success:function(json){
					var html = "";
					var time = "";
					var content = "";
					var person = "";
					if(json){
					for(var i=0;i<json.length;i++){
						time = json[i].evalueTime;
						content = json[i].evalueOpinion;
						person = json[i].evaluator;
						if(!content){
							content = "无";
						}
						if(time){
							time=time.substr(0,10);
						}
						html+="<tr><td>"+content+"</td>"+
				          "<td>"+time+"</td><td>"+person+"</td></tr>";
					}
					}
					$("#case_details").html(html);
					$(".aTagUnderLine_body").show();
					
				}
			});
			
		}
		function closeAlert(){
			$(".aTagUnderLine_body").hide();
		}
	</script>
</body>
</html>
